<#assign ctx=request.contextPath />
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>微工匠管理系统</title>
    <link rel="icon" type="image/x-icon" href="/static/favicon.ico"/>
    <link rel="stylesheet" href="${ctx}/ftl/css/login@2.css">
</head>
<body>
<div class="form">
    <div class="logo">
        <img src="${ctx}/ftl/images/logo@2x.png" alt="">
    </div>
<#--<div class="title">微工匠管理平台</div>-->
    <div class="user" style="border:none">
    <#--<span class="user_icon">-->
                <#--<img src="${ctx}/ftl/images/icon_company.png" alt="">-->
            <#--</span>-->
            <#--<input type="text" placeholder="企业码" id="companyCode" name="companyCode">-->
    </div>
    <div class="user">
            <span class="user_icon">
                <img src="${ctx}/ftl/images/icon_user.png" alt="">
            </span>
        <input type="text" placeholder="登录账号" id="username" name="username">
    </div>
    <div class="user">
            <span class="user_icon">
                <img src="${ctx}/ftl/images/icon_lock.png" alt="">
            </span>
        <input type="password" placeholder="登录密码" id="password" name="password">
    </div>
    <!--
    <div class="validatecode">
        <input type="text" placeholder="短信验证码" name="code">
        <span>获取短信验证码</span>
    </div>
    -->
    <button id="login" style="cursor: pointer">登&nbsp;&nbsp;陆</button>
    <!--
   <div class="forgetpaw"><span>忘记密码？</span></div>
    -->
</div>
</body>
</html>
<script type="text/javascript" src="${ctx}/assets/jquery/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="${ctx}/assets/plugins/layui2.2.6/layui.js"></script>
<script>
    var layer;
    layui.use(['layer'], function () {
        layer = layui.layer;
    });
    $(document).ready(function () {
        $("#login").click(function () {
            login();
        });
    });

    function login() {
        $.ajax({
            type: "POST",
            url: "/admin/login.do",
            data: {
                userName: $("#username").val(),
                password: $("#password").val(),
            },
            dataType: "json",
            success: function (result) {
                console.log(result);
                if (result.flag) {
                    location.href = '/admin/main';
                } else {
                    layer.msg(result.msg, {time: 3000, shift: 6, icon: 5});
                }
            }
        });
    }
</script>
